/*
 * Copyright (c) 2016, FPX and/or its affiliates. All rights reserved.
 * Use, Copy is subject to authorized license.
 */
package com.fpx.xms.api.dto.pds;

import java.util.List;
import java.util.Map;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;

import com.fpx.open.platform.common.constant.SysConstant;
import com.fpx.xms.api.dto.AbstractResponse;

/**
 * pds响应模型
 * @author shiw
 * @date 2016年8月9日
 */
public class PdsResponse extends AbstractResponse {

	private String result;
	
	/** 消息 */
	private String msg;
	
	/** 错误列表 */
	private List<Error> errors;
	
	/** 业务数据 */
	private Map<String, Object> dataMap;

	@Override
	public String getIsSuccess() {
		if(StringUtils.equals("000001", this.result)){
			return SysConstant.YES;
		}
		return SysConstant.NO;
	}

	@Override
	public boolean isSuccess() {
		if(StringUtils.equals("000001", this.result)){
			return true;
		}
		return false;
	}


	@Override
	public boolean isRetry() {
		if(StringUtils.equals("000000", this.result) && CollectionUtils.isNotEmpty(this.errors)){
			for(Error error : this.errors){
				if(StringUtils.equals(error.getErrorCode(), "000099")){
					return true;
				}
			}
		}
		return false;
	}

	/**
	 * @return the result
	 */
	public String getResult() {
		return result;
	}

	/**
	 * @param result the result to set
	 */
	public void setResult(String result) {
		this.result = result;
	}

	/**
	 * @return the msg
	 */
	public String getMsg() {
		return msg;
	}

	/**
	 * @param msg the msg to set
	 */
	public void setMsg(String msg) {
		this.msg = msg;
	}

	/**
	 * @return the errors
	 */
	public List<Error> getErrors() {
		return errors;
	}

	/**
	 * @param errors the errors to set
	 */
	public void setErrors(List<Error> errors) {
		this.errors = errors;
	}

	/**
	 * @return the dataMap
	 */
	public Map<String, Object> getDataMap() {
		return dataMap;
	}

	/**
	 * @param dataMap the dataMap to set
	 */
	public void setDataMap(Map<String, Object> dataMap) {
		this.dataMap = dataMap;
	} 
	

}
